#ifndef NODEITEM_H
#define NODEITEM_H
#include <QGraphicsEllipseItem>
#include <QGraphicsSceneMouseEvent>
#include <QPen>
#include <QBrush>
#include <QPainter>

#include <QDebug>

#include "edgeitem.h"


class EdgeItem;

class NodeItem: public QGraphicsEllipseItem
 {
 public:
     enum { Type = UserType + 1 };

     enum StateType{mPress, sleepState}; Q_ENUMS(StateType)
    // NodeItem();
    // NodeItem(const QRectF &rect);

     StateType stateType;

     NodeItem(qreal ax, qreal ay, qreal w, qreal h);
     ~NodeItem();

     void addEdge(EdgeItem *edge);

    // void getEdge(NodeItem *node);
     EdgeItem  *getEdge(quint32  toIndex);

     void removeEdge(EdgeItem *edge);
     void updateEdge();

     quint32 getIndex();
     void setIndex(quint32  indx);

     int type() const {return Type;}

     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);


 private:
     quint32 nodeIndex;
     void initNode();
     QList<EdgeItem*> connectEdges;

     QPen pen_def;
     QPen pen_current;
     QPen pen_hover;

protected:
     void mousePressEvent(QGraphicsSceneMouseEvent  *event );
     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);

     void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
    // void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
     void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);

 };

#endif // NODEITEM_H
